<template>
 <div class='attr-props-img'>
   <el-form-item>
     <upload :default-url='imgSrc' @getUploadData='getUploadData' />
   </el-form-item>
 </div>
</template>

<script>
import upload from '../../components/Upload';

export default {
  name: 'attr-props-img',
  components: { upload },
  props: {
    defaultUrl: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      imgSrc: '',
    };
  },
  watch: {
    defaultUrl(val) {
      this.imgSrc = val;
    },
  },
  mounted() {
    this.imageUrl = this.defaultUrl;
  },
  methods: {
    // 图片上传成功
    getUploadData({ url = '' }) {
      this.imgSrc = url;
      this.$emit('update:img', url);
    },
  },
};
</script>

<style scoped>

</style>
